use crate::error::AppResult;

/// 获得 casbin policies.
/// # params
/// - role_id 可选，过滤对应的role
/// - resource_id 可选，过滤对应的resource
pub async fn casbin_policies(
    db: &sea_orm::DbConn,
    role_id: Option<i32>,
    resource_id: Option<i32>,
) -> AppResult<Vec<Vec<String>>> {
    Ok(ane_system::casbin_policies(db, role_id, resource_id)
        .await?
        .into_iter()
        .map(|f| vec![format!("role_{}", f.0), f.1, f.2])
        .collect::<Vec<_>>())
}
